//
//  ViewController.swift
//  LeetCodeSummary
//
//  Created by WangYonghe on 2020/5/8.
//  Copyright © 2020 WangYonghe. All rights reserved.
//

import UIKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        print("开始运行")
        let startTime = CFAbsoluteTimeGetCurrent()
        
        //
//        let twoSumObj = TwoSum()
//        let ret = twoSumObj.twoSumSimple(nums: [1,2,3,4,5,6,7], target: 3)
//        print(ret)
//
//        let resultArr = twoSumObj.twoSumResult(nums: [1,2,3,4,5,6,7], target: 8)
//        print(resultArr)
        
//        let obj = CommenPrefix()
//        let arr = obj.longestCommonPrefix([""])
//        print("最长前缀:\(arr)")
        
//        let obj = MySqrt()
//        let num = obj.mySqrtFunc(7)
//        print("平方根结果：\(num)")
        
//        let obj = ReverseNum()
//        let num = obj.reverseNumFunc(-598)
//        print("整数反转结果：\(num)")
        
        
//        let obj = RomanToInt()
//        let num = obj.romanToInt("MCMXCIV")
//        print("罗马数字转整数结果：\(num)")
        
//        let obj = RomanToInt()
//        let num = obj.convenientIdea(1994)
//        print("整数转罗马数字结果：\(num)")
        
        
        //umNum > INT32_MAX || sumNum < Int32.min{
        //print("\(INT32_MAX)\n\(Int32.min)\n\n\n")
        //print("\(INT64_MAX)\n\(Int64.min)")
    
        
        let obj = CombinationSum2()
        let arr = obj.combinationSum3(2, 18)
        print("组合总和结果：\(arr)")
        
        
//        let obj = Permutation()
//        let arr = obj.permutation("abbc")
//        print("组合总和结果：\(arr)")
        
//        let obj = RestoreIpAddresses()
//        let arr = obj.restoreIpAddresses("25525511135")
//        print("复原IP地址结果：\(arr)")
        
        
//        let obj = GetMaximumGold()
//        let goldNum = obj.getMaximumGold([[0,6,0],
//                                          [5,8,7],
//                                          [0,9,0]])
//
//        print("黄金矿工最佳开采路径数量为：\(goldNum)")
        
//        let obj = Subsets()
//        let arr = obj.subsets(["1","2","3"])
//        print("幂集结果：\(arr)")
        
//        let n = 6
//        let obj = SolveNQueens()
//        let arr = obj.solveNQueens(n)
//        print("N皇后(n=\(n))结果：\(arr)")
        
//        let obj = Permute()
//        let arr = obj.permute([1,2,3])
//        print("全排列结果：\(arr)")

//        let obj = PermuteUnique()
//        let arr = obj.permuteUnique([3,3,0,3])
//        print("全排列II结果：\(arr)")

        
//        let obj = NumTilePossibilities()
//        let arr = obj.numTilePossibilities("YYXBTSR")
//        print("活字印刷结果：\(arr)")
        
        
//        let obj = MinSubArrayLen()
//        let lenth = obj.minSubArrayLen(4, [1,4,4])
//        print("长度最小的子数组结果：\(lenth)")
        
//        let obj = FindLength()
//        let lenth = obj.findLength([1,2,3,3,2,1], [3,2,1,4,7,8])
//        print("最长重复子数组结果：\(lenth)")
        
//        let node1 = TreeNode(2)
//        node1.left = TreeNode(1)
//        node1.right = TreeNode(3)
//        node1.right!.right = TreeNode(4)
//
//        let obj = BalanceBST()
//        let node = obj.balanceBST(node1)
//        print("将二叉树平衡：\(node?.val)")
        
        

//        let obj = DivingBoard()
//        let arr = obj.divingBoard(1, 1, 100000)
//        print("跳水板结果：\(arr)")
        
//        let obj = IsSubsequence()
//        let bool = obj.isSubsequence2("abc","ahbgdc")
//        print("判断子序列结果：\(bool)")
        
//        let obj = Intersect()
//        let arr = obj.intersect([1,2,2,1],[2,2])
//        print("两个数组的交集 II：\(arr)")
        
        
        
//        let obj = CalculateMinimumHP()
//        let result = obj.calculateMinimumHP([[-2,-3,3],[-5,-10,1],[10,30,-5]])
//        print("地下城游戏：\(result)")


//        let obj = MinimumTotal()
//        let result = obj.minimumTotal2([[-1],[2,3],[1,-1,-3]])
//        print("三角形路最小路径和：\(result)")
              
        
//        let obj = NumTrees()
//        let result = obj.numTrees3(3)
//        print("不同的二叉搜索树结果：\(result)")
        
//        let obj = SearchInsert()
//        let result = obj.searchInsert([1,3,5,6], 2)
//        print("搜索插入位置结果：\(result)")
        
        
//        let obj = IsInterleave()
//        let bool = obj.isInterleave("aabcc", "dbbca", "aadbbcbcac")
//        print("交错字符串结果：\(bool)")
        
        
//        let obj = FindRepeatNumber()
//        let bool = obj.findRepeatNumber4([2, 3, 1, 0, 2, 5, 3])
//        print("数组中重复的数字：\(bool)")
        
        
//        let obj = SpiralOrder()
//        let arr = obj.spiralOrder2([[1,2,3,4],[5,6,7,8],[9,10,11,12],[13,14,15,16]])
//        print("顺时针打印：\(arr)")
        
        
//        let obj = MinPathSum()
//        let sum = obj.minPathSum([
//          [1,2,5],
//          [3,2,1]
//        ])
//        print("最小路径和：\(sum)")
        
//        let obj = Exist()
//        let bool = obj.exist([
//          ["a"]
//        ],"a")
//        print("矩阵中的路径是否存在：\(bool)")
        
        
//        let obj = SplitArray()
//        let num = obj.splitArray(
//          [7,2,5,10,8]
//        ,2)
//        print("分割数组的最大值：\(num)")
        
//        let obj = LongestIncreasingPath()
//        let num = obj.longestIncreasingPath([
//            [9,9,4],
//            [6,6,8],
//            [2,1,1]
//          ])
//        print("矩阵中的最长递增路径：\(num)")
        
//        let obj = ThreeSumMulti()
//        let num = obj.threeSumMulti2([0,0,0]
//        ,0)
//        print("三数之和的多种可能：\(num)")
        
        
//        let obj = AddStrings()
//        let arr = obj.multiply("9","9")
//        //let arr = obj.addStrings("8638","74040")
//        print("字符串相加：\(arr)")
        
//        let obj = RobChoice()
//        let res = obj.rob2([0,0])
//        print("打家劫舍：\(res)")

        
//        let node1 = TreeNode(1)
//        let node2 = TreeNode(2)
//        let node3 = TreeNode(3)
//        node1.left = node3
//        node3.right = node2
//
//        let obj = RecoverTree()
//        obj.recoverTree(node1)
        //print("找出非升序的位置：\(res)")
        
//        let obj = PalindromePairs()
//        let arr = obj.palindromePairs(["a",""])
//        //let arr = obj.addStrings("8638","74040")
//        print("回文对：\(arr)")
        
//        let obj = BuildTree()
//        let root = obj.buildTree([1,2,3],[3,2,1])
//        print("重建二叉树：\(root)")
        
//        let obj = FindSubsequences()
//        let arr = obj.findSubsequences([4, 6, 7, 7])
//        print("递增子序列：\(arr)")
        
//        let obj = LetterCombinations()
//        let arr = obj.letterCombinations("234")
//        print("电话号码的字母组合：\(arr)")
        
        
//        let obj = ShortestPalindrome()
//        let arr = obj.shortestPalindrome2("abcd")
//        print("最短回文串：\(arr)")
        
//        let obj = CanVisitAllRooms()
//        let arr = obj.canVisitAllRooms([[1],[2],[3],[]])
//        print("钥匙和房间：\(arr)")
        
//        let node1 = TreeNode(1)
//        let node2 = TreeNode(2)
//        let node3 = TreeNode(3)
//        let node5 = TreeNode(5)
//
//        node1.left = node2
//        node1.right = node3
//        node2.right = node5
//
//        let obj = BinaryTreePaths()
//        let arr = obj.binaryTreePaths(node1)
//        print("二叉树的所有路径：\(arr)")
        
//        let obj = GetPermutation()
//        let arr = obj.getPermutation(3, 3)
//         print("全排列：\(arr)")
        
        
        let endTime = CFAbsoluteTimeGetCurrent()
        let string = String(format:"%.2f",(endTime - startTime)*1000)
        
        debugPrint("代码执行时长：\(string)毫秒")
    }


}

